package com.unidentifiable.wechat.controller;

import com.unidentifiable.wechat.service.SubscribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Controller
 * @author unidentifiable
 * @date 2021-02-28
 */
public class SubscribeController {
    @Autowired
    private SubscribeService subscribeService;

    /**
     * 服务器校验
     * @param req 请求
     * @return 校验结果
     */
    @GetMapping("/")
    public String verification(HttpServletRequest req) {
        return subscribeService.verification(req);
    }

    /**
     * 消息事件
     * @param req 请求
     * @return 结果
     */
    @PostMapping("/")
    public boolean subscribeEvent(HttpServletRequest req) {
        String s = subscribeService.subscribeEvent(req);
        return null != s;
    }
}
